package la.iok.hzsvn.lewin.movie.cloud.controller;

import la.iok.hzsvn.lewin.movie.cloud.model.PlayRecordQrCodeInfo;
import la.iok.hzsvn.lewin.movie.cloud.model.QRCodeInfo;
import la.iok.hzsvn.lewin.movie.cloud.service.QRCodeService;
import la.iok.hzsvn.lewin.movie.core.Token;
import la.iok.hzsvn.share.annotations.NotNull;
import la.iok.hzsvn.share.response.SingleDataResponse;
import org.springframework.web.bind.annotation.*;

/**
 * 二维码接口
 */
@RestController
@RequestMapping("qrcode")
public class QRCodeController {
    private final QRCodeService qrCodeService;

    public QRCodeController(QRCodeService qrCodeService) {
        this.qrCodeService = qrCodeService;
    }

    /**
     * 店铺二维码
     * @param id 店铺id
     */
    @GetMapping("shop/{id}")
    public SingleDataResponse<QRCodeInfo> shopQRCode(@NotNull @RequestHeader Token token, @PathVariable Long id){
        return new SingleDataResponse<>(qrCodeService.shopQRCode(token,id));
    }

    /**
     * 房间二维码
     * @param token 操作用户
     * @param id 房间id
     * @return 二维码
     */
    @GetMapping("room/{id}")
    public SingleDataResponse<QRCodeInfo> roomQRCode(@NotNull @RequestHeader Token token, @PathVariable Long id){
        return new SingleDataResponse<>(qrCodeService.roomQRCode(token,id));
    }

    /**
     * 开本记录二维码
     * @param token 操作用户
     * @param id 开本记录id
     * @return 二维码
     */
    @GetMapping("playRecord/{id}")
    public SingleDataResponse<PlayRecordQrCodeInfo> playRecordQRCode(@NotNull @RequestHeader Token token, @PathVariable Long id){
        return new SingleDataResponse<>(qrCodeService.playRecordQRCode(token,id));
    }
}
